package com.zyj.myapplication.Activity;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;

import com.zyj.myapplication.Javabean.YueJian;
import com.zyj.myapplication.Model.UserModel;
import com.zyj.myapplication.R;

import it.sephiroth.android.library.picasso.Picasso;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;

public class AboutYueJianActivity extends AppCompatActivity {
    private TextView yuejian_name, yuejian_content;
    private ImageView yuejian_pic,about_return;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_aboutyuejian);
        initViews();//初始化
        initEvents();//初始化事件
    }

    private void initViews() {
        yuejian_name = (TextView) findViewById(R.id.about_yuejiann);
        yuejian_content = (TextView) findViewById(R.id.about_yuejianc);
        yuejian_pic = (ImageView) findViewById(R.id.about_yuejianp);
        about_return = (ImageView) findViewById(R.id.about_return);
    }

    private void initEvents() {
        about_return.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });

        UserModel usermodel = new UserModel();
        Call<YueJian> call = usermodel.getYueJian();
        call.enqueue(new Callback<YueJian>() {
            @Override
            public void onResponse(Call<YueJian> call, Response<YueJian> response) {
                YueJian yueJian = response.body();
                yuejian_name.setText(yueJian.getCorpname());
                Picasso.with(AboutYueJianActivity.this).load(R.drawable.coachtx).into(yuejian_pic);
                yuejian_content.setText(yueJian.getContact());
            }

            @Override
            public void onFailure(Call<YueJian> call, Throwable t) {

                Toast.makeText(AboutYueJianActivity.this, "获取消息失败", Toast.LENGTH_LONG).show();

            }
        });

    }
}
